//公共对象模型
interface BaseWorkers_Model {
    "WorkId": number,
    "WorkNo": string,
    "WorkName": string,
    "Memo": string,
    "RegKey": string,
    "EditionCode": string,
    "DelFlag": number,
    "EmrRegisterCode": string,
    "OrganizationID": string,
}

class BaseWorkers_ORM {
    public data = {
        dbConn: TSLobsterAPI.Program.GetDbConn(),
        WorkId: 1
    }

    constructor(workid: number) {
        this.data.WorkId = workid;
        this.BaseWorkers.WorkId = workid;
    }

    public BaseWorkers = {
        "model": {
            "WorkId": 0,
            "WorkNo": "",
            "WorkName": "",
            "Memo": "",
            "RegKey": "",
            "EditionCode": "",
            "DelFlag": 0,
            "EmrRegisterCode": "",
            "OrganizationID": ""
        },
        "tablename": "BaseWorkers",
        "key": "WorkId",
        "val": "0",
        "objval": {},
        "query": {},
        "where": "",
        "pageinfo": {},
        "WorkId": 1
    }

    Save(model: BaseWorkers_Model): any {
        this.BaseWorkers.objval = model;
        return TSLobsterAPI.DbHelper.SaveModel(this.data.dbConn, this.BaseWorkers);
    }

    GetList(where?: string) {
        return TSLobsterAPI.OrmMsSql.GetListModel(this.data.dbConn, this.BaseWorkers);
    }
}

interface BaseEmployee_Model {
    "EmpId": number,
    "Name": string,
    "Sex": number,
    "Brithday": string,
    "Szm": string,
    "Pym": string,
    "Wbm": string,
    "DelFlag": string,
    "WorkId": number,
}

class BaseEmployee_ORM {
    public data = {
        dbConn: TSLobsterAPI.Program.GetDbConn(),
        WorkId: 1
    }

    constructor(workid: number) {
        this.data.WorkId = workid;
        this.BaseEmployee.WorkId = workid;
    }

    public BaseEmployee = {
        "model": {
            "EmpId": 0,
            "Name": "",
            "Sex": 0,
            "Brithday": "yyyy-MM-dd",
            "Szm": "",
            "Pym": "",
            "Wbm": "",
            "DelFlag": "",
            "WorkId": 0
        },
        "tablename": "BaseEmployee",
        "key": "EmpId",
        "val": "0",
        "objval": {},
        "query": {},
        "where": "",
        "pageinfo": {},
        "WorkId": 1
    }

    Save(model: BaseEmployee_Model): any {
        this.BaseEmployee.objval = model;
        return TSLobsterAPI.DbHelper.SaveModel(this.data.dbConn, this.BaseEmployee);
    }

    GetList(where?: string) {
        return TSLobsterAPI.OrmMsSql.GetListModel(this.data.dbConn, this.BaseEmployee);
    }

    GetModel(id): BaseEmployee_Model {
        this.BaseEmployee.val = id;
        return TSLobsterAPI.DbHelper.GetModel(this.data.dbConn, this.BaseEmployee) as BaseEmployee_Model;
    }
}


interface BaseUser_Model {
    "UserID": number,
    "EmpID": number,
    "Code": string,
    "PassWord": string,
    "GroupId": number,
    "Lock": string,
    "Memo": string,
    "UserType": number,
    "DoctorPost": string,
    "NursePost": string,
    "IsAdmin": number,
    "WorkId": number,
    "AntibioticLevelOne": number,
    "AntibioticLevelTwo": number,
    "AntibioticLevelThree": number,
    "Poison": number,
    "Narcotic": number,
}

class BaseUser_ORM {
    public data = {
        dbConn: TSLobsterAPI.Program.GetDbConn(),
        WorkId: 1
    }

    constructor(workid: number) {
        this.data.WorkId = workid;
        this.BaseUser.WorkId = workid;
    }

    public BaseUser = {
        "model": {
            "UserID": 0,
            "EmpID": 0,
            "Code": "",
            "PassWord": "",
            "GroupId": 0,
            "Lock": "",
            "Memo": "",
            "UserType": 0,
            "DoctorPost": "",
            "NursePost": "",
            "IsAdmin": 0,
            "WorkId": 0,
            "AntibioticLevelOne": 0,
            "AntibioticLevelTwo": 0,
            "AntibioticLevelThree": 0,
            "Poison": 0,
            "Narcotic": 0
        },
        "tablename": "BaseUser",
        "key": "UserID",
        "val": "0",
        "objval": {},
        "query": {},
        "where": "",
        "pageinfo": {},
        "WorkId": 1
    }

    Save(model: BaseUser_Model): any {
        this.BaseUser.objval = model;
        return TSLobsterAPI.DbHelper.SaveModel(this.data.dbConn, this.BaseUser);
    }

    GetList(where?: string) {
        return TSLobsterAPI.OrmMsSql.GetListModel(this.data.dbConn, this.BaseUser);
    }

    GetModel(id): BaseUser_Model {
        this.BaseUser.val = id;
        var model = TSLobsterAPI.DbHelper.GetModel(this.data.dbConn, this.BaseUser) as BaseUser_Model;
        model.AntibioticLevelOne = model.AntibioticLevelOne || 0;
        model.AntibioticLevelTwo = model.AntibioticLevelTwo || 0;
        model.AntibioticLevelThree = model.AntibioticLevelThree || 0;
        model.Poison = model.Poison || 0;
        model.Narcotic = model.Narcotic || 0;
        return model;
    }
}

interface BaseDeptLayer_Model {
    "LayerId": number,
    "PId": number,
    "Name": string,
    "WorkId": number,
}

class BaseDeptLayer_ORM {
    public data = {
        dbConn: TSLobsterAPI.Program.GetDbConn(),
        WorkId: 1
    }

    constructor(workid: number) {
        this.data.WorkId = workid;
        this.BaseDeptLayer.WorkId = workid;
    }

    public BaseDeptLayer = {
        "model": {
            "LayerId": 0,
            "PId": 0,
            "Name": "",
            "WorkId": 0
        },
        "tablename": "BaseDeptLayer",
        "key": "LayerId",
        "val": "0",
        "objval": {},
        "query": {},
        "where": "",
        "pageinfo": {},
        "WorkId": 1
    }

    Save(model: BaseDeptLayer_Model): any {
        this.BaseDeptLayer.objval = model;
        return TSLobsterAPI.DbHelper.SaveModel(this.data.dbConn, this.BaseDeptLayer);
    }

    GetList(where?: string) {
        if (where) {
            this.BaseDeptLayer.where = " where " + where;
        }
        return TSLobsterAPI.OrmMsSql.GetListModel(this.data.dbConn, this.BaseDeptLayer);
    }
}


interface BaseDept_Model {
    "DeptId": number,
    "Layer": number,
    "Name": string,
    "Pym": string,
    "Wbm": string,
    "Szm": string,
    "Code": string,
    "DelFlag": string,
    "SortOrder": number,
    "Memo": string,
    "WorkId": number,
}

class BaseDept_ORM {
    public data = {
        dbConn: TSLobsterAPI.Program.GetDbConn(),
        WorkId: 1
    }

    constructor(workid: number) {
        this.data.WorkId = workid;
        this.BaseDept.WorkId = workid;
    }

    public BaseDept = {
        "model": {
            "DeptId": 0,
            "Layer": 0,
            "Name": "",
            "Pym": "",
            "Wbm": "",
            "Szm": "",
            "Code": "",
            "DelFlag": "",
            "SortOrder": 0,
            "Memo": "",
            "WorkId": 0
        },
        "tablename": "BaseDept",
        "key": "DeptId",
        "val": "0",
        "objval": {},
        "query": {},
        "where": "",
        "pageinfo": {},
        "WorkId": 1
    }

    Save(model: BaseDept_Model): any {
        this.BaseDept.objval = model;
        return TSLobsterAPI.DbHelper.SaveModel(this.data.dbConn, this.BaseDept);
    }

    GetList(where?: string) {
        if (where) {
            this.BaseDept.where = " where " + where;
        }
        return TSLobsterAPI.OrmMsSql.GetListModel(this.data.dbConn, this.BaseDept);
    }
}

interface BaseGroup_Model {
    "GroupId": number,
    "Name": string,
    "DelFlag": string,
    "Admin": string,
    "Everyone": string,
    "Memo": string,
    "Property": string,
    "WorkId": number,
}

class BaseGroup_ORM {
    public data = {
        dbConn: TSLobsterAPI.Program.GetDbConn(),
        WorkId: 1
    }

    constructor(workid: number) {
        this.data.WorkId = workid;
        this.BaseGroup.WorkId = workid;
    }

    public BaseGroup = {
        "model": {
            "GroupId": 0,
            "Name": "",
            "DelFlag": "",
            "Admin": "",
            "Everyone": "",
            "Memo": "",
            "Property": "",
            "WorkId": 0
        },
        "tablename": "BaseGroup",
        "key": "GroupId",
        "val": "0",
        "objval": {},
        "query": {},
        "where": "",
        "pageinfo": {},
        "WorkId": 1
    }

    Save(model: BaseGroup_Model): any {
        this.BaseGroup.objval = model;
        return TSLobsterAPI.DbHelper.SaveModel(this.data.dbConn, this.BaseGroup);
    }

    GetList(where?: string) {
        if (where) {
            this.BaseGroup.where = " where " + where;
        }
        return TSLobsterAPI.OrmMsSql.GetListModel(this.data.dbConn, this.BaseGroup);
    }

    GetModel(id): BaseGroup_Model {
        this.BaseGroup.val = id;
        return TSLobsterAPI.DbHelper.GetModel(this.data.dbConn, this.BaseGroup) as BaseGroup_Model;
    }
}

interface BaseMenu_Model {
    "MenuId": number,
    "SortId": number,
    "Name": string,
    "DllName": string,
    "FunName": string,
    "FunWcfName": string,
    "ModuleId": number,
    "PMenuId": number,
    "MenuToolBar": string,
    "MenuLookBar": string,
    "Memo": string,
    "Image": string,
    "UrlId": string,
    "UrlName": string,
    "BindSQL": string,
    "WorkId": number,
}

class BaseMenu_ORM {
    public data = {
        dbConn: TSLobsterAPI.Program.GetDbConn(),
        WorkId: 1
    }

    constructor(workid: number) {
        this.data.WorkId = workid;
        this.BaseMenu.WorkId = workid;
    }

    public BaseMenu = {
        "model": {
            "MenuId": 0,
            "SortId": 0,
            "Name": "",
            "DllName": "",
            "FunName": "",
            "FunWcfName": "",
            "ModuleId": 0,
            "PMenuId": 0,
            "MenuToolBar": "",
            "MenuLookBar": "",
            "Memo": "",
            "Image": "",
            "UrlId": "",
            "UrlName": "",
            "BindSQL": "",
            "WorkId": 0
        },
        "tablename": "BaseMenu",
        "key": "MenuId",
        "val": "0",
        "objval": {},
        "query": {},
        "where": "",
        "pageinfo": {},
        "WorkId": 1
    }

    Save(model: BaseMenu_Model): any {
        this.BaseMenu.objval = model;
        return TSLobsterAPI.DbHelper.SaveModel(this.data.dbConn, this.BaseMenu);
    }

    GetList(where?: string) {
        return TSLobsterAPI.OrmMsSql.GetListModel(this.data.dbConn, this.BaseMenu);
    }
}
